package org.eduapp.trains.utils;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

public class UtilsHibernate {
	
	/**
	 * QBC中多个OR的查询
	 * @param crit1
	 * @param crit2
	 * @return
	 */
	public static Criterion QBC_OR(Criterion crit1, Criterion crit2){
		if (crit1 == null) {
			return crit2;
		}
		if (crit2 == null) {
			return crit1;
		}
		return Restrictions.or(crit1, crit2);
	}
	
	public static Criterion QBC_AND(Criterion crit1, Criterion crit2){
		if (crit1 == null) {
			return crit2;
		}
		if (crit2 == null) {
			return crit1;
		}
		return Restrictions.and(crit1, crit2);
	}
	
}
